package com.etl.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.etl.bean.User;
import com.etl.dao.IUserDao;
import com.etl.service.IUserService;

@Service("userService")
public class UserServiceImpl implements IUserService{

	@Resource
	private IUserDao userDao;
	
	public IUserDao getIUserDao() {
		return userDao;
	}

	public void setIUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}

	@Override
	public List<User> findAllUsers() {
		return userDao.findAllUsers();
	}

	@Override
	public User findUserById(int userId) {
		return userDao.findUserById(userId);
	}

	@Override
	public User findUserByUserName(String userName) {
		return userDao.findUserByUserName(userName);
	}

	@Override
	public User findUserByUserAccount(String userAccount) {
		return userDao.findUserByUserAccount(userAccount);
	}

	@Override
	public void insertUser(User user) {
		userDao.insertUser(user);		
	}

	@Override
	public void deleteUser(User user) {
		userDao.deleteUser(user);
	}

	@Override
	public void updateUser(User user) {
		userDao.updateUser(user);		
	}

	@Override
	public boolean checkLogin(String userAccount, String userPwd) {
		User user = userDao.findUserByUserAccount(userAccount);
		if (userPwd.equals(user.getUserPwd())) {
			return true;
		}
		return false;
	}

}
